home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / ablits.c next >
C/C++ Source or Header  |  1997-04-16  |  3KB  |  155 lines

  1.  
  2. #include <stdio.h>
  3. #include <aline.h>
  4. #include "flicker.h"
  5.  
  6.  
  7. #define R_NOP 5
  8. #define R_CLR 0
  9. #define R_SET 15
  10. #define R_XOR 6
  11. #define R_CPY 3
  12. #define R_OR  7
  13. #define R_SCOOP 4
  14.  
  15. copy_blit(width, height, sx, sy, spt, srow_bytes, dx, dy, dpt, drow_bytes)
  16. WORD width, height, sx, sy, srow_bytes, dx, dy, drow_bytes;
  17. WORD *spt, *dpt;
  18. {
  19. struct bbblock b;
  20.  
  21. b.b_wd = width;
  22. b.b_ht = height;
  23. b.plane_ct = 4;
  24. b.op_tab[0] = b.op_tab[1] = b.op_tab[2] = b.op_tab[3] = 3;  /*replace */
  25.  
  26. b.s_xmin = sx;
  27. b.d_xmin = dx;
  28. b.s_ymin = sy;
  29. b.d_ymin = dy;
  30. b.s_form = spt;
  31. b.d_form = dpt;
  32.  
  33. b.s_nxwd = b.d_nxwd = BITPLANES*2;
  34. b.s_nxln = srow_bytes;
  35. b.d_nxln = drow_bytes;
  36. b.s_nxpl = b.d_nxpl = 2;
  37. b.p_addr = NULL;
  38. ablit(&b);
  39. }
  40.  
  41. clip_from_screen(c, screen)
  42. register Cel *c;
  43. WORD *screen;
  44. {
  45. copy_blit(c->width, c->height, c->xoff, c->yoff,  screen, 160, 
  46.     0, 0, c->image, Raster_line(c->width) );
  47. copy_words(sys_cmap, c->cmap, 16);
  48. }
  49.  
  50.  
  51.  
  52. dest_clip_block(b)
  53. register struct bbblock *b;
  54. {
  55. register WORD x2, y2;
  56.  
  57. if ((x2 = b->d_xmin) >= XMAX || 
  58.     (y2 = b->d_ymin) >= YMAX)
  59.     return(0);
  60. if ( (x2+=b->b_wd) <= 0 || (y2+=b->b_ht) <= 0)
  61.     return(0);
  62. if (b->d_xmin < 0)
  63.     {
  64.     b->b_wd -= (0 - b->d_xmin);
  65.     b->s_xmin += (0 - b->d_xmin);
  66.     b->d_xmin = 0;
  67.     }
  68. if (b->d_ymin < 0)
  69.     {
  70.     b->b_ht -= (0 - b->d_ymin);
  71.     b->s_ymin += (0 - b->d_ymin);
  72.     b->d_ymin = 0;
  73.     }
  74. if (x2 > XMAX)
  75.     b->b_wd -= x2-XMAX;
  76. if (y2 > YMAX)
  77.     b->b_ht -= y2-YMAX;
  78. return(1);
  79. }
  80.  
  81. copy_celblit(x, y, cel)
  82. WORD x, y;
  83. register Cel *cel;
  84. {
  85. struct bbblock b;
  86.  
  87. b.b_wd = cel->width;
  88. b.b_ht = cel->height;
  89. b.plane_ct = 4;
  90. b.op_tab[0] = b.op_tab[1] = b.op_tab[2] = b.op_tab[3] = 3;  /*replace */
  91.  
  92. b.s_xmin = 0;
  93. b.d_xmin = x+cel->xoff;
  94. b.s_ymin = 0;
  95. b.d_ymin = y+cel->yoff;
  96. b.s_form = cel->image;
  97. b.d_form = cscreen;
  98.  
  99. b.s_nxwd = b.d_nxwd = BITPLANES*2;
  100. b.s_nxln = Raster_line(cel->width);
  101. b.d_nxln = 160;
  102. b.s_nxpl = b.d_nxpl = 2;
  103. b.p_addr = NULL;
  104. if (dest_clip_block(&b))
  105.     ablit(&b);
  106. }
  107.  
  108. nozero_celblit(x, y, cel)
  109. WORD x, y;
  110. register Cel *cel;
  111. {
  112. struct bbblock b;
  113.  
  114.  
  115. x += cel->xoff;
  116. y += cel->yoff;
  117.  
  118. /* set up the "scoop out" blit */
  119. b.b_wd = cel->width;
  120. b.b_ht = cel->height;
  121. b.plane_ct = BITPLANES;
  122. b.op_tab[0] = b.op_tab[1] = b.op_tab[2] = b.op_tab[3] = 1; /*and*/
  123. b.d_form = cscreen;
  124. b.d_xmin = x;
  125. b.d_ymin = y;
  126. b.s_xmin = b.s_ymin = 0;
  127. b.s_form = cel->mask;
  128. b.s_nxpl = 0;
  129. b.s_nxwd = 2;
  130. b.s_nxln = (((cel->width+15)>>3)&0xfffe);
  131. b.d_nxpl = 2;
  132. b.d_nxwd = BITPLANES*2;
  133. b.d_nxln = 160;
  134. b.p_addr = NULL;
  135. if (dest_clip_block(&b))
  136.     ablit(&b);
  137.  
  138. /* and xor in the image through the hole */
  139. b.b_wd = cel->width;
  140. b.b_ht = cel->height;
  141. b.plane_ct = BITPLANES;
  142. b.op_tab[0] = b.op_tab[1] = b.op_tab[2] = b.op_tab[3] = R_XOR; /*replace*/
  143. b.d_xmin = x;
  144. b.d_ymin = y;
  145. b.s_xmin = b.s_ymin = 0;
  146. b.s_form = cel->image;
  147. b.s_nxpl = 2;
  148. b.s_nxwd = 8;
  149. b.s_nxln = Raster_line(cel->width);
  150. b.p_addr = NULL;
  151. if (dest_clip_block(&b))
  152.     ablit(&b);
  153. }
  154.  
  155.